package cn.wh.mybatis.binding;

import java.lang.reflect.Proxy;
import java.util.Map;

/**
 * @Author wanghao
 * @Date 2022-05-11 11:58
 * @Description: TODO
 */
public class MapperProxyFactory<T> {
    private final Class<T> mapperInterface;

    public MapperProxyFactory(Class<T> mapperInterface) {
        this.mapperInterface = mapperInterface;
    }

    public T newInstance(Map<String,String>sqlSession){
        final MapperProxy<T> mapperProxy=new MapperProxy<>(sqlSession,mapperInterface);
        return (T) Proxy.newProxyInstance(mapperInterface.getClassLoader(),new Class[]{mapperInterface}, mapperProxy);
    }

}
